<extend name="Public/base"/>

<block name="body">
    <div class="am-cf am-u-md-12 header-title">
        <h2>导航管理</h2>
    </div>

    <div class="am-cf am-u-md-12 am-margin-top">
        <div class="am-btn-group">
            <a class="am-btn am-btn-primary" href="{:U('add','pid='.$pid)}">新 增</a>
            <button class="am-btn am-btn-danger ajax-post confirm" url="{:U('del')}" target-form="ids">删 除</button>
            <button class="am-btn am-btn-success list_sort" url="{:U('sort',array('pid'=>I('get.pid',0)),'')}">排序</button>
        </div>
    </div>

    <div class="am-cf am-u-md-12 am-margin-top">
        <table class="am-table am-table-striped">
            <thead>
                <tr>
                    <th class="row-selected">
                        <input class="checkbox check-all" type="checkbox">
                    </th>
                    <th>ID</th>
                    <th>导航名称</th>
                    <th>导航地址</th>
                    <th>新窗口打开</th>
                    <th>排序</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <notempty name="list">
                <volist name="list" id="channel">
                    <tr>
                        <td><input class="ids row-selected" type="checkbox" name="id[]" value="{$channel['id']}"> </td>
                        <td>{$channel.id}</td>
                        <td><a href="{:U('Channel/add?pid='.$channel['id'])}">{$channel.title} <i class="am-icon am-icon-plus-square"></i></a></td>
                        <td>{$channel.url}</td>
                        <th><eq name="channel.target" value="1">是<else/>不是</eq></th>
                        <td>{$channel.sort}</td>
                        <td>
                            <a title="编辑" href="{:U('edit?id='.$channel['id'].'&pid='.$pid)}">编辑</a>
                            <a href="{:U('setStatus?ids='.$channel['id'].'&status='.abs(1-$channel['status']))}" class="ajax-get">{$channel.status|show_status_op}</a>
                            <a class="confirm ajax-get" title="删除" href="{:U('del?id='.$channel['id'])}">删除</a>
                        </td>
                    </tr>
                    <if condition="!empty($channel['_child'])">
                    <volist name="channel['_child']" id="item">
                    <tr>
                        <td><input class="ids row-selected" type="checkbox" name="id[]" value="{$item['id']}"> </td>
                        <td>{$item.id}</td>
                        <td><span class="am-padding-left"><a href="#">— {$item.title}</a></span></td>
                        <td>{$item.url}</td>
                        <th><eq name="item.target" value="1">是<else/>不是</eq></th>
                        <td>{$item.sort}</td>
                        <td>
                            <a title="编辑" href="{:U('edit?id='.$item['id'].'&pid='.$pid)}">编辑</a>
                            <a href="{:U('setStatus?ids='.$item['id'].'&status='.abs(1-$item['status']))}" class="ajax-get">{$item.status|show_status_op}</a>
                            <a class="confirm ajax-get" title="删除" href="{:U('del?id='.$item['id'])}">删除</a>
                        </td>
                    </tr>
                    </volist>
                    </if>
                </volist>
                <else/>
                <td colspan="6" class="text-center"> aOh! 暂时还没有内容! </td>
                </notempty>
            </tbody>
        </table>
    </div>
</block>

<block name="script">
<script type="text/javascript">
    $(function() {
        //点击排序
        $('.list_sort').click(function(){
            var url = $(this).attr('url');
            var ids = $('.ids:checked');
            var param = '';
            if(ids.length > 0){
                var str = new Array();
                ids.each(function(){
                    str.push($(this).val());
                });
                param = str.join(',');
            }

            if(url != undefined && url != ''){
                window.location.href = url + '/ids/' + param;
            }
        });
    });
</script>
</block>